﻿using DataScripter.Database;
using DataScripter.Scripting;
using DataScripter.Scripting.ScriptDefinitions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

namespace DataScripter.UnitTests.EngineTests
{
    [TestClass]
    public class WhenEngineIsinitialized
    {
        private readonly Engine _engine;
        private readonly Mock<IDatabaseFactory> _databaseFactoryMock;

        public WhenEngineIsinitialized()
        {
            Mock<IDatabaseStructure> structureMock = new Mock<IDatabaseStructure>();
            _databaseFactoryMock = new Mock<IDatabaseFactory>(MockBehavior.Strict);
            
            _engine = new Engine();
            IScriptDefinition scriptDefinition = new ScriptDefinition("", _engine);
            _engine.RegisterType(scriptDefinition);

            _databaseFactoryMock.Setup(f => f.CreateDatabaseStructure(_engine)).Returns(structureMock.Object);
        }

        [TestMethod]
        public void ThereShouldBeNoTablesToScript()
        {
            Assert.AreEqual(0, _engine.Resolve<IScriptDefinition>().ScriptRequests.Count);
        }

    }
}
